Skip to content

Expression rebase#4

Merged
kristfal merged 20 commits into
rnmapbox:masterfrom
mfazekas:expression
Apr 30, 2019
Merged

Expression rebase#4
kristfal merged 20 commits into
rnmapbox:masterfrom
mfazekas:expression

Conversation

@mfazekas
Copy link
Copy Markdown
Contributor

@mfazekas mfazekas commented Apr 14, 2019

This is a rebase of @nitaliano's expression branch to the current master

This is work in progress.

  • android 7.9.0 and ios 4.9.0(latest)
  • demo runs on android and ios
  • moved some of the user tracking functionality from old MapView.java to Camera.java, but it still WIP

Known issues:

  • MarkerViews probably gone, but not removed - todo either implement fully or remove
  • We need to clean up stuff like userTracking - i think it's followUserLocation & followUserMode on Camera
  • Cleanup/refactor location related stuff in RCTMGLCamera.java - i think there is lot of logic we use from LocationComponent, so we don't need our own impl

Migration Docs:

  1. in package.json change @mapbox/react-native-mapbox-gl to @mapbox-react-native/maps, to use this branch use "@react-native-mapbox/maps": "github:mfazekas/maps#expression"
  2. in Podfile change
    - pod 'react-native-mapbox-gl', :path => '../node_modules/@mapbox/react-native-mapbox-gl'

    + pod 'react-native-mapbox-gl', :path => '../node_modules/@react-native-mapbox/maps'
  3. in settings.gradle change
    - project(':mapbox-react-native-mapbox-gl').projectDir = new File(rootProject.projectDir, '../node_modules/@mapbox/react-native-mapbox-gl/android/rctmgl')
   
    + project(':mapbox-react-native-mapbox-gl').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-mapbox/maps/android/rctmgl')
  4. replace import Mapbox in .js files:
    - import Mapbox from '@mapbox/react-native-mapbox-gl'
    + import Mapbox from '@react-native-mapbox/maps'
  5. Stylesheet fixes (no Stylesheet.create, Stylesheet.identity)
    - Stylesheet.create({foo: 'bar', baz: Stylesheet.identity('foo123')})
    +{foo:'bar', baz:['get','foo123']}
  6. Some mapview attributes are now needs to be in a Camera:
    - <MapView visibleCoordinateBounds={[...]}>...</...>
    + <MapView><Camera bounds={{sw:[...],ne: [...], ..}}...>...</...>
  7. Some mapview attributes are now needs to be UserLocation component:
    - <MapView showUserLocation >...</...>
    + <MapView><UserLocation...>...</...>

@mfazekas mfazekas force-pushed the expression branch 2 times, most recently from 4f40040 to 9e73f52 Compare April 16, 2019 11:46
@mfazekas
Copy link
Copy Markdown
Contributor Author

@nitaliano @kristfal question regarding expressions, currently we treat value an expression if it's an array and the first item is a string. The issue is with attributes like textFont, they supposed to be an array of text, we need to diferrentiate string array literals from expressions.

So the question is that how do we figure out that

This is a value array of strings:

{ 
   ...,
   textFont: ["Open Sans Regular","Arial Unicode MS Regular"]
}

but this is an expression:

{
   ...
   textFont: ['get', 'font']
}

I see the following solutions:

  1. we require expressions to be constructed via special syntax:
    { ... textFont: expression('get','font') ...}
  2. we require string array literals to be cosntructed via special syntax:
    { ... textFont: literal('Open Sans Regular', 'Arial Unicode MS Regular') ...}
  3. we implement isExpression (this, and we only treat arrays expression if they start with a string, this string is one of known expression operator. The js and c++ mapbox has this, but they have a list of expressions from expressionsRegistry and we don't seems to have access to that. So we might miss some usefull expressions...

@kristfal
Copy link
Copy Markdown
Member

Very good question, and good work on this!

As far as developer ergonomics, I think alternative 3 is the strongest. I sense that option 1 or 2, or both combined, will likely be a root cause for questions from devs coming from both native and JS backgrounds.

Yes, we likely do need to maintain a list of supported expression evaluators that are the lowest common denominator of iOS and Android SDKs. However, I think the cost of maintaining this list is lower than the time spent writing documentation and responding to questions regarding the implementation.

If there is a way to extract supported expressions from the gl-js lib, that would be great. On the flip side, it would also require us to keep a close eye on versioning as the JS side often leads in feature support over the native SDKs.

I’m on mobile now, so I haven’t looked at at how we solve it currently, but iirc, we do maintain a list of supported style operators for this repo specifically. I assume something similar for expressions kinda makes sense. @nitaliano built this afaik, so I believe he may be better at giving an opinion about this.

Thanks again for your contributions!

@alexiri
Copy link
Copy Markdown
Contributor

alexiri commented Apr 26, 2019

The GeoJSON Source example shows a Failed prop type: Invalid prop 'style' supplied to 'FillLayer' warning. I checked the definition of the FillLayer and the style prop looks like it's defined just fine. Any idea what that's about?

@mfazekas
Copy link
Copy Markdown
Contributor Author

mfazekas commented Apr 26, 2019

The GeoJSON Source example shows a Failed prop type: Invalid prop 'style' supplied to 'FillLayer' warning. I checked the definition of the FillLayer and the style prop looks like it's defined just fine. Any idea what that's about?

you can see the check the allowed styles for FillLayer bellow, i assume the style has not allowed keys:

https://github.com/mfazekas/maps/blob/571b3b6724f5dd5563560cb5127e1115ce37177c/javascript/utils/styleMap.js#L52-L151

In particular fillAntialias bool doesn't seems to be allowed by the style spec, but i don't think it's related to this branch does it?

@alexiri
Copy link
Copy Markdown
Contributor

alexiri commented Apr 27, 2019

You're right, that's the issue, I missed that.

@nitaliano is the code generation correct? According to the style spec file, fill-antialias is supposed to be a boolean (and it has data-constant as it's property-type, not sure if that's relevant), but in the autogenerated code it's treated as an expression. Is that right? If so, I guess the example app needs to change.

@mfazekas
Copy link
Copy Markdown
Contributor Author

mfazekas commented Apr 27, 2019

As far as developer ergonomics, I think alternative 3 is the strongest. I sense that option 1 or 2, or both combined, will likely be a root cause for questions from devs coming from both native and JS backgrounds.

@kristfal actually my question was a bit rushed. It sounds that both on ios and java passing a fontStack (eg string array) to textFont works. Because either NSExpression expressionWithMGLJSONObject- objc and Expression.raw - java, handles this for us or expressions are not evaluated for textFont. In any case both ios and android supports ['lateral', [...]] too should someone needs to force something to literal. Right now i'm treating every array where the first item is a string as an expression. We can improve on that later if needed.

It might make sense to merge the branch sooner than later. There are stuff to be cleaned up like MarkerViews on android, android camera cleanup, docs, etc.

@mfazekas mfazekas changed the title [WIP] Expression rebase Expression rebase Apr 27, 2019
@kristfal
Copy link
Copy Markdown
Member

Great!

Awesome work on this. I see you’ve been working weekends, so thanks a lot man.

If things are stable in terms of crashes, I think it makes sense to merge. I haven’t run this branch myself on our prod repo, but I’m still keen on getting it into master asap. We can label this as a prerelease to communicate it clearly with the community.

Once it is in and stability is verified/good, I think we should publish on NPM and deprecate the old repo.

@mfazekas
Copy link
Copy Markdown
Contributor Author

@kristfal we're using it in our app we're developing so base part of it is stable (Map, Camera, Symbol, FillLayer, Offline both on android+ios). I have no doubt that there are instable/non-consitent parts.

My concern is that if we wait for this branch to be fully stabilized in every aspect, changes will appear on master, and merging will delay stuff even more.

@systemlevel
Copy link
Copy Markdown
Contributor

@mfazekas Thank you for your work on this. I share your sentiments on not waiting too long to get this merged.

@kristfal
Copy link
Copy Markdown
Member

Hey again @mfazekas, just to clarify: Yes, I think we should merge sooner than later. Do you have ownership to do so? If not, would you like me to merge now or wait?

After that merge, we tag it as a prerelease and if there are issues, we'll fix as we go forward.

@kristfal
Copy link
Copy Markdown
Member

Added you as a collaborator @mfazekas and merged #3 (which caused conflicts here), feel free to merge to master at your own leisure.

mfazekas and others added 15 commits April 30, 2019 19:11
Android fix: style values with array and first as number is a number array not an expression
Android fix: dont animate camera if duration is 0
ios: fix style values for vectors/colors
camera bounds compare fix
* iOS: add react warning if geojson is invalid
* android: use promise for last known location
* if last location is null do not override non null last location
* Annotation: only add symbol if style is defined and do not add children as child of symbol layer
* iOS: accept number as a color
1. allow bounds to be any order not just ne/sw (so works like ios)
2. updateFilter should have a way to clear
alexiri and others added 5 commits April 30, 2019 19:13
…tmaps

ios: added some warnings and nil check for images
* putMap consumes it's second arg so we need to clone payload before adding it
* Marked MapView#setCamera  method as deprecated.

	new file:   CHANGELOG.md
@mfazekas mfazekas closed this Apr 30, 2019
@mfazekas mfazekas mentioned this pull request Apr 30, 2019
@mfazekas
Copy link
Copy Markdown
Contributor Author

somehow i've got this closed by mistake

@mfazekas mfazekas reopened this Apr 30, 2019
@mfazekas
Copy link
Copy Markdown
Contributor Author

@kristfal i'm not a Member of react-native-mapbox, but i don't seems to have write access for the maps project, so i cannot merge. Please merge.

kép

@kristfal kristfal merged commit f0b469d into rnmapbox:master Apr 30, 2019
@systemlevel
Copy link
Copy Markdown
Contributor

@mfazekas @kristfal Testing out the new merge a little this evening. I'm getting a behavior where my initial map zoom and initial center coordinates are not working.

      <Mapbox.MapView
        zoomLevel={8}
        centerCoordinate={[-111.8678, 42.2866]}
        style={styles.map}
        showUserLocation={true}
      >

Map loads at zoom 0 as show in the screenshot:

Screen Shot 2019-04-30 at 4 30 53 PM

The pre-merge code loads zoom and center coords correctly.

Do you think this is related to this merge in some way? Perhaps not? Not sure why that stopped working.

@ericpalakovichcarr
Copy link
Copy Markdown

@systemlevel Hey, thanks for kicking the tires on the post-merge repo. I plan on doing the same sometime in the next few days.

Given master finally has all this new code merged in, maybe this should be a new issue that references this pull request?

@systemlevel
Copy link
Copy Markdown
Contributor

systemlevel commented Apr 30, 2019

@BigSassy Thank you good idea I'll create an issue regarding this. I've got a few more things to note as well as I go through this. Looking forward to your feedback as well. Please let us know anything you find.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants